package letsjava.rmi;

import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import java.util.*;

public class WarehouseImpl extends UnicastRemoteObject implements Warehouse{
	private HashMap<String,Double> map;
	private HashMap<String,Product> product;
	public WarehouseImpl() throws RemoteException{
		map = new HashMap<String,Double>();
		product = new HashMap<String,Product>();
		map.put("apple", 1.11);
		map.put("pear", 2.11);
		
	}
	
	public void add(String a, Product b){
		//b.setLocation(this);
		product.put(a, b);
	}
	@Override
    public double getPrice(String a) throws RemoteException {
	    // TODO Auto-generated method stub
	    return map.get(a);
    }
	@Override
    public Product getProduct(List<String> a) throws RemoteException {
	    // TODO Auto-generated method stub
		for(String s:a){
			Product p = product.get(s);
			if(s!=null){
				return p;
			}
		}
		
	    return null;
    }

}
